<?php namespace testsacvoyage\storage;

require_once("testsacvoyage/storage/AbstractTest.php");

class LimiterTest extends \testsacvoyage\storage\AbstractTest {

	public function setUp() {
		$this->_array=array('a', 'b', 'c', 'd', 'e', 'f');
		$this->_iterator=new \ArrayIterator($this->_array);
	}

	/*
	 * 
	 */
	public function testDefault() {
		$limiter=new \sacvoyage\storage\Limiter($this->_iterator);
		$this->assertEquals($this->_array, iterator_to_array($limiter)); 
	}

	/*
	 * 
	 */
	public function testCount() {
		$limiter=new \sacvoyage\storage\Limiter($this->_iterator, 3);
		$this->assertEquals(array('a', 'b', 'c'), iterator_to_array($limiter)); 
	}

	/*
	 * 
	 */
	public function testStart() {
		$limiter=new \sacvoyage\storage\Limiter($this->_iterator, new \sacvoyage\Object(array('start'=>3)));		
		$this->assertEquals(array('d', 'e', 'f'), iterator_to_array($limiter)); 
	}
	
	/*
	 * 
	 */
	public function testBoth() {
		$limiter=new \sacvoyage\storage\Limiter($this->_iterator, array(2,2));
		$this->assertEquals(array('c', 'd'), iterator_to_array($limiter)); 
	}	
	
	/*
	 * 
	 */
	public function testOutOfBounds() {
		$limiter=new \sacvoyage\storage\Limiter($this->_iterator, new \sacvoyage\Object(array('start'=>100)));		
		$this->assertEquals(array(), iterator_to_array($limiter));

		$limiter=new \sacvoyage\storage\Limiter($this->_iterator, 100);
		$this->assertEquals($this->_array, iterator_to_array($limiter));
	}	
	
	
	
}

?>
